﻿using System;
using System.Reflection;

namespace MyTestRunner.Domain
{
    /// <summary>
    /// Represents the result of a test run.
    /// </summary>
    public class TestRunResult
    {
        private MethodInfo testMethod;
        private Exception unexpectedException;

        /// <summary>
        /// Constructor.
        /// </summary>
        public TestRunResult(MethodInfo testMethod)
            :this(testMethod, null)
        {
        }

        /// <summary>
        /// Constructor.
        /// </summary>
        public TestRunResult(MethodInfo testMethod, Exception unexpectedException)
        {
            this.testMethod = testMethod;
            this.unexpectedException = unexpectedException;
        }

        /// <summary>
        /// Gets the method to which this result applies.
        /// </summary>
        public MethodInfo Method
        {
            get { return this.testMethod; }
        }

        /// <summary>
        /// Gets the exception that was unexpectedly thrown.
        /// </summary>
        public Exception UnexpectedException
        {
            get { return this.unexpectedException; }
        }

        /// <summary>
        /// Gets the result of the test run.
        /// </summary>
        public bool IsSuccess
        {
            get { return this.unexpectedException == null; }
        }
    }
}
